<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ page import="java.sql.*" %>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
    
    <title>My JSP 'change.jsp' starting page</title>
    
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">
	<!--
	<link rel="stylesheet" type="text/css" href="styles.css">
	-->

  </head>
  
  <body>
  <%	Connection con;
    	Statement sql; 
    	ResultSet rs;
   		String name="";
   		String id="";
   		String address="",tel="";
    	if(request.getParameter("id")!=null)
       		id=request.getParameter("id");
       
    	try{  Class.forName("com.mysql.jdbc.Driver");
    		}
   	 	catch(Exception e){
       		out.println("忘记把MySQL数据库的JDBC-数据库驱动程序复制到JDK的扩展目录中");
    		}
    	try { 
    		String uri= "jdbc:mysql://localhost:3306/peopletext";
          	String user="root";
         	String password="kamui5201";
          	con=DriverManager.getConnection(uri,user,password);
          	sql=con.createStatement();
          	rs=sql.executeQuery("SELECT * FROM pinfo where id="+id+"");
          	if(rs.next())
          	{
          		name=rs.getString(1);
             	tel=rs.getString(2);
             	address=rs.getString(3);
          	}
        	con.close();
         	}
        catch(SQLException e){ 
          out.print(e);
    	}
 %>
 修改：<br>
    <form action ="dochange.jsp" method=post>
    <table border=1>
    <tr><td>联系人姓名：</td>
    	<td><input type="text" name="name" value="<%=name%>"></td></tr>
    <tr><td>联系人电话：</td>
    	<td><input type="text" name="tel" value="<%=tel%>"></td></tr>
    <tr><td>家庭地址：</td>
    	<td><input type="text" name="address" value="<%=address%>"></td></tr>
    </table>
    <input type="hidden" name="id" value="<%=id%>" />
    <input type="submit" value="修改">
    <input type="reset" value="重置"> 
 </form>
  </body>
</html>
